using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CarRentalSystem.Repository;
using static CarRentalSystem.IServers.ICarServices;

namespace CarRentalSystem.Servers
{
     public abstract class CarServices<TEntity> : ICarServices<TEntity> where TEntity : class, new()
    {
        protected ICarRepository<TEntity> _base;
        public async Task<bool> CreateAsync(TEntity entity)
        { 
            return await _base.CreateAsync(entity);
        }
            

        public async Task<bool> DeleteAsync(TEntity entity)
        {
            return await _base.DeleteAsync(entity);
        }

        public async Task<TEntity> FindByIdAsync(int id)
        {
            return await _base.FindByIdAsync(id);
        }

        public async Task<List<TEntity>> FindAllAsync()
        {
            return await _base.FindAllAsync();
        }

        public async Task<List<TEntity>> FindManyAsync(System.Linq.Expressions.Expression<Func<TEntity, bool>> exp)
        {
            return await _base.FindManyAsync(exp);
        }

        public async Task<TEntity> FindOneAsync(System.Linq.Expressions.Expression<Func<TEntity, bool>> exp)
        {
            return await _base.FindOneAsync(exp);
        }

        public async Task<bool> UpdateAsync(TEntity entity)
        {
            return await _base.UpdateAsync(entity);
        }
    }
}